package opc.read;

import opc.read.config.PathConf;
import opc.read.realopc.UseJsonMultiRead;
import opc.read.sycread.ByReadUseJson2;
import opc.read.sycread.ByReadUseJson2Multi;
import org.jinterop.dcom.common.JIException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * @Description:
 * @author: liyuan
 * @data 2021-01-06 10:19
 * <p>
 * 早期的执行命令 java -Djava.io.tmpdir=d:/ProDataAccess/xianhe/lib -jar xianhe.jar
 */
@SpringBootApplication
public class App {
    private static final Logger logger = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) throws IOException, JIException, InterruptedException {
        //我写的最原始的
//        ByReadUseJson.DemoAPI();
        SpringApplication.run(App.class, args);
//        ByReadUseJson2.DemoAPI();
        if(PathConf.isSimServer){
            ByReadUseJson2Multi.DemoAPI();
        }else{
            UseJsonMultiRead.readAndSend();
        }
//
//        使用异步方式访问的测试文件
//        ByReadUseJson4.DemoAPI();
//        ByRead.DemoAPI();
//        ByDemoRead.DemoAPI();
//        ByDemoAsyRead.DemoAPI();
//        MyProcess();
    }

    //启动脚本的测试
    private static void MyProcess() {
        String cmd = "D:\\ProDataAccess\\ya\\xianheJar\\xianhe.bat";
//        StringBuilder builder = new StringBuilder();
//        builder.append("xianhe.bat");
//        File path = new File("D:\\ProDataAccess\\ya\\xianheJar\\");
        try {
            Runtime.getRuntime().exec(cmd);
            Thread.sleep(1000);
            System.exit(0);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
